//
//  CustomAlertViewController.m
//  SdkDemo
//
//  Created by HalloWorld on 2017/6/6.
//  Copyright © 2017年 legendsec. All rights reserved.
//

#import "CustomAlertViewController.h"

@interface CustomAlertViewController ()
@property (nonatomic, strong) UIView* customView;
@end

@implementation CustomAlertViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Lifecycle

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    
    self.customView.frame = CGRectMake((self.view.frame.size.width-self.customView.frame.size.width)/2, 50, self.customView.frame.size.width, self.customView.frame.size.height);
}

- (void)addCustomView:(UIView*)customView {
    
    self.customView = customView;
    
    if(customView)
    {
        [self.view addSubview:customView];
    }
}

+ (CustomAlertViewController *)alertViewController
{
    CustomAlertViewController *alertController = [CustomAlertViewController alertControllerWithTitle:@"信息" message:@"\n\n\n\n\n\n\n" preferredStyle:UIAlertControllerStyleAlert];
    
    return alertController;
}

- (void)addButtonTitle:(NSString*)title
                 style:(UIAlertActionStyle)style
               handler:(void (^)(UIAlertAction *action))handler
{
    UIAlertAction* action = [UIAlertAction actionWithTitle:title
                                                     style:style
                                                     handler:handler];
    [self addAction:action];
}

- (void)showInViewController:(UIViewController *)vc
{
    [vc presentViewController:self animated:YES completion:nil];
}

@end
